//
//  BookDetailsViewController.m
//  BookDetails
//
//  Created by dlios on 15-3-7.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "BookDetailsViewController.h"

@interface BookDetailsViewController ()

@end

@implementation BookDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    //self.title = @"书   名";
    //bself.title = self.bookSale.name;

//    self.detailsImage = [UIImage imageNamed:@"mine_header_bkg.png"];
//    BookSale *bookSale = [self.allSaleBookArray objectAtIndex:indexPath.row];
//    NSURL *url = [NSURL URLWithString:bookSale.image_url];
//    //sd请求图片
//    [cell.bookCoverImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"picLib_default@2x.png"]];
   // NSString *imageStr = self.bookSale.image_url;
    
    UIImage *backImage = [UIImage imageNamed:@"iconfont-fanhui.png"];
    backImage = [backImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:backImage style:UIBarButtonItemStylePlain target:self action:@selector(backBarButtonItemAction:)];
    
    self.navigationItem.leftBarButtonItem = backButton;
    
    self.detailsImageView = [[UIImageView alloc] initWithFrame:CGRectMake(70, 0, 220, 230)];
    NSURL *url = [NSURL URLWithString:self.detailsImageStr];
    [self.detailsImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"picLib_default@2x.png"]];
    //self.detailsImageView.image = self.detailsImage;
    //NSLog(@"22222222222%@",url);

    self.detailsImageView.userInteractionEnabled = YES;
    [self.view addSubview:self.detailsImageView];
    
    
    //设置价格Label
    self.priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.detailsImageView.frame.origin.x - 20 , self.detailsImageView.frame.origin.y + self.detailsImageView.frame.size.height + 30, 110, 30)];
    //self.priceLabel.text = @"￥ 250.00";
    self.priceLabel.text = self.priceStr;
    self.priceLabel.font = [UIFont systemFontOfSize:18];
    self.priceLabel.textColor = [UIColor redColor];
    [self.view addSubview:self.priceLabel];
    
    
    //设置书名Label
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.detailsImageView.frame.origin.x -38, self.priceLabel.frame.origin.y + self.priceLabel.frame.size.height + 10, 350, 30)];
    //self.nameLabel.text = @"张慧说 :  约嘛?约嘛?约嘛?约嘛!";
    self.nameLabel.text = self.nameStr;
    self.nameLabel.font = [UIFont systemFontOfSize:21];
    [self.view addSubview:self.nameLabel];
    

    //设置作者Label
    self.authornameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.nameLabel.frame.origin.x + 15, self.nameLabel.frame.origin.y + self.nameLabel.frame.size.height + 10, 300, 30)];
    //self.authornameLabel.text = @"作者:   张慧";
    self.authornameLabel.text = self.authornameStr;
    [self.view addSubview:self.authornameLabel];
    
    //设置收藏按钮
    self.collectionButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.collectionButton.frame = CGRectMake(self.priceLabel.frame.origin.x + self.priceLabel.frame.size.width + 60, self.detailsImageView.frame.origin.y + self.detailsImageView.frame.size.height + 10, 56, 56);
    [self.collectionButton setImage:[UIImage imageNamed:@")H5]LNJW)4NH4_H@GS]YE29.jpg"] forState:UIControlStateHighlighted];
    [self.collectionButton setImage:[UIImage imageNamed:@"P9LPG(6)@HU0X~XYKEK%~23.jpg"] forState:UIControlStateNormal];
    [self.view addSubview:self.collectionButton];
    
    //设置分享按钮
    UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    shareButton.frame = CGRectMake(self.priceLabel.frame.origin.x + self.priceLabel.frame.size.width + 120, self.detailsImageView.frame.origin.y + self.detailsImageView.frame.size.height + 10, 56, 56);
    [shareButton setImage:[UIImage imageNamed:@"iconfont-fenxiang-3.png"] forState:UIControlStateNormal];
    [self.view addSubview:shareButton];

    [shareButton addTarget:self action:@selector(shareButton:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    //设置简介label
    self.subNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.authornameLabel.frame.origin.x, self.authornameLabel.frame.origin.y + self.authornameLabel.frame.size.height, 300, 110)];
    self.subNameLabel.text = self.subNameStr;
    self.subNameLabel.numberOfLines = 0;
    //self.subNameLabel.backgroundColor = [UIColor blackColor];
    [self.view addSubview:self.subNameLabel];
    //NSLog(@"11111111111%@",self.bookSale.subname);
    
    //设置评价button
    self.discussButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.discussButton.frame = CGRectMake(self.authornameLabel.frame.origin.x - 20, self.authornameLabel.frame.origin.y + self.authornameLabel.frame.size.height + 115, 320, 45);
    self.discussButton.backgroundColor = [UIColor colorWithRed:128/255.0 green:85/255.0 blue:62/255.0 alpha:1];
    //[self.discussButton setBackgroundImage:[UIImage imageNamed:@"sharebg.png"] forState:UIControlStateNormal];
    self.discussButton.layer.cornerRadius = 23;
    [self.discussButton setTitle:@"评 价 详 情" forState:UIControlStateNormal];
    //self.discussButton.tintColor = [UIColor blackColor];
    [self.view addSubview:self.discussButton];
    [self.discussButton addTarget:self action:@selector(discussAtion:) forControlEvents:UIControlEventTouchUpInside];
    
    
}
//导航栏左侧的返回按钮
- (void)backBarButtonItemAction:(UIBarButtonItem *)barButton
{
    [self.navigationController popViewControllerAnimated:YES];
}


//跳转评价详情页面
- (void)discussAtion:(UIButton *)button
{
    DiscussDetailsViewController *discussDetailsVC = [[DiscussDetailsViewController alloc] init];
    
    discussDetailsVC.productId = self.productId;
    
    //NSLog(@"222222222222222222222%@",discussDetailsVC.productId);
    
    
    [self.navigationController pushViewController:discussDetailsVC animated:YES];
}
//分享按钮触发的方法
- (void)shareButton:(UIButton *)button
{
    
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"507fcab25270157b37000010"
                                      shareText:@"你要分享的文字"
                                     shareImage:[UIImage imageNamed:@"icon.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToRenren, UMShareToQzone, nil]
                                       delegate:self];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
